package com.djx.goods.chush;

import com.alibaba.fastjson.JSONObject;
import com.djx.common.domain.Type;
import com.djx.goods.service.impl.TypeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class GoodsChush{
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Resource
    private TypeServiceImpl typeService;
    public void chuSh(){
        List<Type> list = typeService.getList();
        ListOperations<String, String> forList = redisTemplate.opsForList();
        forList.leftPushAll("type",JSONObject.toJSONString(list));
    }
}
